#include <stdio.h>
#include <stdlib.h>

#include "encoder.h"

int encode( unsigned char* yuvBuf, unsigned char* h264Buf, int& h264BufLen, CX264VideoEncoder& encoder )
{
// 	CX264VideoEncoder encoder;
	int width = 640;
	int height = 480;
	int bAnnexB = 1;
// 	uint8_t sps[MAX_PS_SIZE];
// 	uint8_t pps[MAX_PS_SIZE];
// 	int spsLen = 0;
// 	int ppsLen = 0;
	int frameType = X264_TYPE_AUTO;


// 	if (!encoder.Open(width, height, bAnnexB, sps, &spsLen, pps, &ppsLen))
// 	{
// 		fprintf(stdout, "Failed to open encoder!\n");
// 		return -1;
// 	}

	if (!encoder.Encode(yuvBuf, h264Buf, &h264BufLen, &frameType, bAnnexB))
	{
		fprintf(stdout, "Error while encoding frame.\n");
		return -1;
	}

/*	encoder.Close();*/

	return 0;
}